import time

from selenium.webdriver.common.by import By

from pageobjects.BasePage import BasePage


class LoginPage(BasePage):
    __INPUT_NAME = (By.CSS_SELECTOR, '#username')
    __INPUT_PASSWORD = (By.CSS_SELECTOR, '#password')
    __CLICK_SUBMIT = (By.CSS_SELECTOR, '#submit')
    def login(self, name, password):
        # 输入账号
        self.do_clear(self.__INPUT_NAME)
        self.do_send_keys(self.__INPUT_NAME, name)
        # 输入密码
        self.do_clear(self.__INPUT_PASSWORD)
        self.do_send_keys(self.__INPUT_PASSWORD, password)
        # 点击登录
        self.do_click(self.__CLICK_SUBMIT)

        from pageobjects.ListPage import ListPage
        return ListPage(self.driver)
